package GameStats;

import java.util.ArrayList;

import javax.swing.SwingUtilities;

import GameModel.eCardColor;
import GameModel.mCard;
import GameModel.mCardCombo;
import GameModel.mGame;
import GameModel.mGameStat;
import Player.mPlayer;
import Server.mRegisteredPlayers;

/**
*Generiertes Spiel zum Testen der Richtigkeit der Spielstatistiken
*
*@author Christopher Vogel
*/

public class _test_dGameStats {
	public static void main(String[] args) {

		SwingUtilities.invokeLater(new Runnable() { // was macht invokeLater?
					public void run() {
						 try {
							 
							 ArrayList<mPlayer> AL = mRegisteredPlayers.get();
							mCard dummycard = null;	
							 System.out.println(AL.toString());
								mPlayer p1 = AL.get(0);
								mPlayer p2 = AL.get(1);
								mPlayer p3 = AL.get(2);
								
								ServerListener.ServerListener.Player=p1;
								
								mGame game = new mGame("Mein Spiel", 3, 100, p1);
								game.addPlayerKonto(p2);
								game.addPlayerKonto(p3);
								
								
								 //No joker!
								ArrayList<mCard> set = new ArrayList<mCard>();
//								 dummycard = new mCard(eCardColor.GREEN, 8);
//								 set.add(dummycard);
//								 dummycard = new mCard(eCardColor.GREEN, 8);
//								 set.add(dummycard);
//								 dummycard = new mCard(eCardColor.GREEN, 8);
//								 set.add(dummycard);
//								 dummycard = new mCard(eCardColor.JOKER, 1);
//								 set.add(dummycard);
//								 dummycard = new mCard(eCardColor.JOKER, 2);
//								 set.add(dummycard);
//								 dummycard = new mCard(eCardColor.JOKER, 3);
//								 set.add(dummycard);
								 
								 game.newCardCombo(set, game.getCurrentPlayer());
								 mCardCombo cc = game.getLastCardCombo();
							//	ArrayList
								 
								 game.addBet("big_bet", p1);
								 game.addBet("big_bet", p2);
								 game.addBet("big_bet", p3);
								 
								 
								 
								 for (int i=0;i<14;i++) {
							set.clear();
									 set.add(game.getHandCardsByPlayer(game.getCurrentPlayer()).get(0));
									 
								 System.out.println("-----------------------------------------");
								// System.out.println(cc.getCardList());
								 System.out.println("turn is valid: "+game.newCardCombo(set, game.getCurrentPlayer()));
								 System.out.println("-----------------------------------------");
								 game.addPassPlayer(game.getCurrentPlayer());
								 game.addPassPlayer(game.getCurrentPlayer());
								 }
								 
						for (int i=0;i<14;i++) {
							set.clear();
									 set.add(game.getHandCardsByPlayer(game.getCurrentPlayer()).get(0));
									// System.out.println(cc.getCardList());
								 System.out.println("-----------------------------------------");
								 System.out.println("turn is valid: "+game.newCardCombo(set, game.getCurrentPlayer()));
								 System.out.println("-----------------------------------------");
								 if (game.getLastCardCombo()!=null && game.getCurrentPlayer()!=null) {
								 game.addPassPlayer(game.getCurrentPlayer());
								 }
								 }
								 
								 
								 for (mGameStat gs: game.getPlayerIngameKonto()) {
									 System.out.println("Spieler "+gs.getPlayer().getUserName()+" hat folgende Punktzahl:  "+gs.getGamePoints());
								 }
								// System.out.println(cc.getCardList());
								 new vMainFrame(game);
								 
							 } catch (Exception e) {
								 e.printStackTrace();
							 }

						

					}
				});
	}
}
